﻿<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="org.springside.modules.security.domain.UserSession"%>
<%@page import="org.springside.core.Constants"%>
<%@page import="cn.firstsoft.modules.note.service.logic.NoteSettingManager"%>
<%@page import="cn.firstsoft.firstframe.web.FirstFrameBeanFactory"%>
<%@ include file="/common/taglibs2.jsp" %>
<fmt:message key="footer_message_1" var="footer_message_1"/>
<fmt:message key="footer_message_2" var="footer_message_2"/>
<fmt:message key="footer_message_3" var="footer_message_3"/>
<fmt:message key="footer_message_4" var="footer_message_4"/>
<fmt:message key="footer_message_5" var="footer_message_5"/>
<fmt:message key="footer_message_label1" var="footer_message_label1"/>
<fmt:message key="footer_message_label2" var="footer_message_label2"/>
<fmt:message key="footer_message_label3" var="footer_message_label3"/>
<fmt:message key="footer_message_label4" var="footer_message_label4"/>
<fmt:message key="footer_message_label5" var="footer_message_label5"/>
		 	</TD>
		 	<td width="5">&nbsp;</td>
         </TR>
	</TBODY>
 </TABLE>

<!--
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 height="20">
  <TBODY>
  <TR>
    <TD>&nbsp;&nbsp;&nbsp;</TD>
    </TR>
  </TBODY>
</TABLE>
 -->
 	</td>
</tr>
<%-- 
 <tr>
	<td width="100%">
		<table class="status_table" style="height:0px;" cellSpacing=0 cellPadding=0>
		  <tr>
		    <td></td>
		    
		    <td><SPAN class="status_bottom"></SPAN></td>
		    <td align="center">
		    <c:set var="eas" value="<%=Constants.EAS%>"/>
			<c:set var="integrationStyle" value="<%=Constants.INTEGRATION_STYLE_EAS%>"/>
			<c:if test="${!eas||(eas&&integrationStyle!=2)}">
		    <SPAN class="status_bottom">&copy;1993-2011 ${footer_message_label1}</SPAN>
		    </c:if>
		    </td>
		    <td align="right"></td>
		    <td width="20">&nbsp;</td>
		  </tr>
		</table>
<!--</Div> //main end-->
	</td>
</tr>--%>
</table>




<DIV id=eMeng
style="Z-INDEX: 99999; LEFT: 0px; VISIBILITY:hidden; WIDTH: 180px; POSITION: absolute; TOP: 0px; HEIGHT: 116px; BACKGROUND-COLOR: #addee0">
<TABLE cellSpacing=0 cellPadding=0 width=280 height=200 border=0 background="../../themes/${sessionScope.loginUser.theme}/images/newtitle.jpg">
  <TBODY>
  <TR >
        <TD  height=20 style="COLOR: #ffffff; "   vAlign=bottom width=245 >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${footer_message_1}</TD>
    <TD style="PADDING-RIGHT: 2px; PADDING-TOP: 2px" vAlign=center align=right
    width=12><SPAN title=${footer_message_2}
      style="FONT-WEIGHT: bold; FONT-SIZE: 12px; CURSOR: hand; COLOR: red; MARGIN-RIGHT: 4px"
      onclick="$('eMeng').style.visibility='hidden';Set_Cookie('userClose','1','','/','','');"><img src="../../themes/${sessionScope.loginUser.theme}/images/close.gif"></SPAN></TD></TR>
  <TR>
    <TD colSpan=3 width=280>
      <DIV
      style="PADDING-LEFT: 13px; PADDING-BOTTOM: 5px; line-height:20px; WIDTH: 100%; COLOR: #1f336b; PADDING-TOP: 10px; HEIGHT: 100%">
      <div align="left" id="eMeng_Count"></div><br>
	  <div align="left" id="eMeng_Content"></div>
      <div align="right" id="eMeng_More"></div>
      </DIV></TD></TR></TBODY></TABLE></DIV>


<%
	UserSession userSession = (UserSession) request.getSession().getAttribute(Constants.USER_IN_SESSION);
	NoteSettingManager noteSettingManager=(NoteSettingManager)FirstFrameBeanFactory.getBean("noteSettingManager");
    java.util.Map<String,String> map=new java.util.HashMap<String,String>();
    map.put("userXXid_i_eq", userSession.getId().toString());
    java.util.List<cn.firstsoft.modules.note.domain.NoteSetting> list=noteSettingManager.findNoteSetting(map);

    if((list.isEmpty() && Constants.MYNOTE_DEFAULT_SHOW.equals("1")) || (!list.isEmpty() && list.get(0).getIsShow()==1)){
%>

<script src='<c:url value="/dwr/util.js"/>'></script>
<script src='<c:url value="/dwr/interface/ajaxNoteManager.js"/>'></script>
<script type="text/javascript" for="BianQianText" event="onclick">
	if(innerText.replace(/\s/g,"")=="${footer_message_label2}")
	{
		style.color="";
		innerText=""
	}
</script>
<script language="JavaScript" type="text/JavaScript">

	addIframe($('eMeng'),$('eMeng').scrollWidth,$('eMeng').scrollHeight);

	var userid=<%=userSession.getId()%>;
	function saveNote(){
		if(BianQianLayer.style.display==''){
			var text=BianQianText.innerText;
			//控制提醒不能超过15行

			if (text.split('\r\n').length > maxBQColumn) {
				if(!confirm("${footer_message_label5}")){
					return;
				}
			}
			//ajaxNoteManager.saveAjaxNotes(userid, text);
			text=encodeURI(text);
			text=encodeURI(text);
			

			new Ajax.Request('<c:url value="/modules/note/note.do?method=ajaxSave"/>', {method: 'post',postBody:'text='+text, onSuccess:function(t){
				if(t.responseText!='true'){
					alert("${footer_message_label3}!");
				}else{
					new Ajax.Request('<c:url value="/modules/note/note.do?method=ajaxList"/>', {method: 'post', onSuccess:function(t){
						if(t.responseText!=''){
							BianQianText.innerHTML=t.responseText;
						}
					}});
					// dmp:PT046299  浮动提示中编辑保存后，便签列表页面没有自动刷新 
					// 如果当前firstframe_main_area 显示的是 便签列表页面,则需要将此页面进行刷新,以同步数据.
					var firstframe_main_area_URI = '<c:out value="${pageContext.request.requestURI}"/>';
					var method = '<c:out value="${param.method}"/>';
					if (firstframe_main_area_URI.indexOf('note/note.do') > 0 && method == "edit"){
						refleshMainLocalArea('../../modules/note/note.do?method=edit');
					}
					
					// end  dmp:PT046299  by yiping_sun 2011-02-24
				}
			}});

		}
	}

	var color1 = "";
	var divLocationX;
	var divLocationY;
	<%if(!list.isEmpty()){%>
		color1 = "<%=list.get(0).getNoteColor()%>";
		divLocationX = <%=list.get(0).getCoordinatesX()%>
    	divLocationY = <%=list.get(0).getCoordinatesY()%>
	<%}%>

	if(color1=="null" || color1==""){
		color1 = "#ffffcc";
	}

    if(divLocationX == null && divLocationY == null){
		divLocationX = "document.body.offsetWidth-220";
		divLocationY = "document.body.offsetHeight-220";
	}


	if(!document.getElementById('BianQianLayer')){
		var html="<div id=\"BianQianLayer\" style=\"z-index:9999;display:${sessionScope.isShowBQ};position:absolute;width:190px;height:150px;background-color:"+color1+";left:expression("+divLocationX+");top:expression("+divLocationY+");\">"+
				"<div  id=\"toolbar\" style=\"border-top:solid 1 #dddddd;padding-top:2px;border-left:solid 1 #dddddd;border-right:solid 1 #dddddd;height:20px;\" align=\"right\">"+
				"<span style='color:#999999;'>${footer_message_label4}</span>"+
				"<span onClick=\"BianQianLayer.style.background=this.style.background;saveColor();\" style=\"cursor:hand;background:fff8f8;width:;border:solid 1 #dddddd;width:13;font-size:10px; margin-right:2px\"></span>"+
				"<span onClick=\"BianQianLayer.style.background=this.style.background;saveColor();\" style=\"cursor:hand;background:f2f2ff;width:;border:solid 1 #dddddd;width:13;font-size:10px; margin-right:2px\"></span>"+
				"<span onClick=\"BianQianLayer.style.background=this.style.background;saveColor();\" style=\"cursor:hand;background:f7fff0;width:;border:solid 1 #dddddd;width:13;font-size:10px; margin-right:2px\"></span>"+
				"<span onClick=\"BianQianLayer.style.background=this.style.background;saveColor();\" style=\"cursor:hand;background:ffffcc;width:;border:solid 1 #dddddd;width:13;font-size:10px; margin-right:2px\"></span>&nbsp;"+
				"<span onClick=\"saveNote();\" style=\"cursor:hand; text-decoration:underline; font-size:9pt\"><img src=\"../../themes/${sessionScope.loginUser.theme}/images/save.gif\" align=\"absmiddle\" onmouseout=\"this.border=0;\" onmouseover=\"this.border=1;\"></span>"+
				"<span cancelBubble=true onClick=\"BianQianLayer.style.display='none';noshow();\" style=\"cursor:hand; text-decoration:underline; font-size:9pt\"><img src=\"../../themes/${sessionScope.loginUser.theme}/images/close_.gif\" align=\"absmiddle\" onmouseout=\"this.border=0;\" onmouseover=\"this.border=1;\"></span>&nbsp;"+
				"</div>"+
				"<div id=\"BianQianText\" onkeydown=\"countLine()\" contentEditable style=\"overflow:auto;word-break:break-all;border-bottom:solid 1 #dddddd;border-left:solid 1 #dddddd;border-right:solid 1 #dddddd;height:130px;color:#999999;font-size:14px;font-size:12px\">${footer_message_label2}</div>"+
				"</div>"+
				"";
		document.write(html);
		addIframe($('BianQianLayer'));
	}
	//dmp:BT518552 add by sunyiping 2011-03-02 最多支持15行输入，当15行以后想再输入回车键，不响应。

	var maxBQColumn = 15;
	function countLine() {
		event.cancelBubble=true;
		if(event.altKey && event.keyCode==83) {
			saveNote();
		}
		else if(event.keyCode==13) {
			var arrays = BianQianText.innerHTML.split("</P>");
			if (arrays.length > maxBQColumn) {
				event.returnValue = false;
			}
		}
	}//BT518552 end
	
	//ajaxNoteManager.getAjaxNotes(userid, function(text){BianQianText.innerHTML=text;});

	new Ajax.Request('<c:url value="/modules/note/note.do?method=ajaxList"/>', {method: 'post', onSuccess:function(t){
		if(t.responseText!=''){
			BianQianText.innerHTML=t.responseText;
		}
	}});
	function noshow(){
		new Ajax.Request('<c:url value="/modules/note/note.do?method=ajaxNoShow&isShow=0"/>');
	}
	function saveColor(){
		if(BianQianLayer.style.display==''){
			var color = BianQianLayer.style.background;
			new Ajax.Request('<c:url value="/modules/note/noteSetting.do?method=ajaxSaveColor&color="/>'+color);
		}
	}
	
	//modify by yuan_zeng 2012-6-4
	document.attachEvent('onkeydown',  function(){
		if(event.altKey){
			if(event.keyCode==67){
				BianQianLayer.style.display='none';
				noshow();
			}else if(event.keyCode==87){
				new Ajax.Request('<c:url value="/modules/note/note.do?method=ajaxNoShow&isShow=1"/>');
				BianQianLayer.style.display='';
				BianQianText.focus();
				if(document.selection){
					var range = document.selection.createRange();
					var newNode=document.createElement("span");
					BianQianText.lastChild.appendChild(newNode);
					range.moveToElementText(BianQianText.lastChild.lastChild);
					range.select();
				}
			}
		}
	});
	
</script>

<%-- zxq, 2012-06-13, BUG:BT688131,放弃以前自写代码，使用scriptaculous 自带属性 --%>
<script type="text/javascript">
	new Draggable('BianQianLayer',{handle:'toolbar',
		snap: function(x, y, draggable) {
			function constrain(n, lower, upper) {
			   if (n > upper) return upper;
			   else if (n < lower) return lower;
			   else return n;
			}
			var element = draggable.element.getDimensions( ); 
			var parent = document.body;
			return [
			   constrain(x, 0, parent.clientWidth - element.width), 
			   constrain(y, 0, parent.clientHeight - element.height) 
			];
		},
		onEnd:function(){
			new Ajax.Request('<c:url value="/modules/note/noteSetting.do?method=ajaxSaveCoordinates"/>'
					+'&x='+$('BianQianLayer').offsetLeft
					+'&y='+$('BianQianLayer').offsetTop,{method:'post'});
		}
	});
</script>

<%}%>
<div style="display:none" id="Constants_webIM" name="<%=Constants.WEBIM%>"></div>
<%if("true".equals(Constants.WEBIM)){%>
<div style="display:none" id="Constants_webIM_maxSessionJoinUsers" name="<%=cn.firstsoft.modules.webim.Constants.SESSION_MAX_JOINUSERS%>"></div>
<div style="display:none" id="Constants_webIM_maxDefaultDroupUsers" name="<%=cn.firstsoft.modules.webim.Constants.DEFINED_GROUP_MAX_USER_COUNT%>"></div>
<div style="display:none" id="Iframe_webIM_flag" name="${webIMIsIframe}"></div>	
<div style="display:none" id="Constants_webIM_refreshFrequency" name="<%=Constants.MESSAGE_CHECK_INTERVAL%>"></div>	
<%if(Constants.MESSAGE_NOTICE_SHOW.equals("true")){%><div style="display:none" id="webIM_showNoticeMessage"></div><%}%>
<%}%>		
</body>
<style type="text/css">

</style>


<script language="javascript">

if(document.getElementById("Constants_webIM").name == "true"){
	document.write('<div style="display:none" id="webIM_loginUser" name="${sessionScope.loginUser.name}"></div>');
	document.write('<div style="display:none" id="webIM_currentUser" name="${sessionScope.loginUser.id}"></div>');
	document.write('<div style="display:none" id="webIM_currentUserSex" name="${sessionScope.loginUser.sex}"></div>');
	document.write('<div style="display:none" id="webIM_themePath" name="${sessionScope.loginUser.themePath}"></div>');
	
	document.write('<script language="javascript" src="<c:url value="/dwr/interface/chatUserManager.js"/>"><\/script>');
	document.write('<script language="javascript" src="<c:url value="/dwr/interface/chatWindowManager.js"/>"><\/script>');
	document.write('<script language="javascript" src="<c:url value="/dwr/interface/chatRefreshManager.js"/>"><\/script>');
	
	document.write('<script language="javascript" src="<c:url value="/components/datepicker/WdatePicker.js"/>"><\/script>');
	document.write('<script language="javascript" src="<c:url value="/scripts/webim/webim.min.js"/>"><\/script>');
}



</script>
	
</html>